package MineSweeper;

import java.awt.Graphics;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JButton;

public class MyButton extends JButton{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	int type;
	
	public MyButton(int type){
		this.type = type;
	}	
	
	// paint for buttons
	public void paintComponent(Graphics g){
		super.paintComponent(g);
		Image img = null;
		switch (type){
		case  8 :
			img = (new ImageIcon("./button/number8.jpg")).getImage();
			g.drawImage(img, 0, 0, getWidth(),getHeight(),null);
			break;
		case  7 :
			img = (new ImageIcon("./button/number7.jpg")).getImage();
			g.drawImage(img, 0, 0, getWidth(),getHeight(),null);
			break;
		case  6 :
			img = (new ImageIcon("./button/number6.jpg")).getImage();
			g.drawImage(img, 0, 0, getWidth(),getHeight(),null);
			break;
		case  5 :
			img = (new ImageIcon("./button/number5.jpg")).getImage();
			g.drawImage(img, 0, 0, getWidth(),getHeight(),null);
			break;
		case  4 :
			img = (new ImageIcon("./button/number4.jpg")).getImage();
			g.drawImage(img, 0, 0, getWidth(),getHeight(),null);
			break;
		case  3 :
			img = (new ImageIcon("./button/number3.jpg")).getImage();
			g.drawImage(img, 0, 0, getWidth(),getHeight(),null);
			break;
		case  2 :
			img = (new ImageIcon("./button/number2.jpg")).getImage();
			g.drawImage(img, 0, 0, getWidth(),getHeight(),null);
			break;
		case  1 :
			img = (new ImageIcon("./button/number1.jpg")).getImage();
			g.drawImage(img, 0, 0, getWidth(),getHeight(),null);
			break;
		case  0 :
			img = null;
			break;
		case -1 :
			img = (new ImageIcon("./button/flag.jpg")).getImage();
			g.drawImage(img, 0, 0, getWidth(),getHeight(),null);
			break;
		case -2 : 
			img = (new ImageIcon("./button/button.jpg")).getImage();
			g.drawImage(img, 0, 0, getWidth(),getHeight(),null);
			break;
		case -3 :
			img = (new ImageIcon("./button/button2.jpg")).getImage();
			g.drawImage(img, 0, 0, getWidth(),getHeight(),null);
			break;
		case -4 :
			img = null;
			break;
		case -5 :
			img = (new ImageIcon("./button/flagoverstate.jpg")).getImage();
			g.drawImage(img, 0, 0, getWidth(),getHeight(),null);
			break;
		case -6 :
			img = (new ImageIcon("./button/unknown.jpg")).getImage();
			g.drawImage(img, 0, 0, getWidth(),getHeight(),null);
			break;
		case -7 :
			img = (new ImageIcon("./button/unknownoverstate.jpg")).getImage();
			g.drawImage(img, 0, 0, getWidth(),getHeight(),null);
			break;
		case -8 :
			img = (new ImageIcon("./button/unknownselect.jpg")).getImage();
			g.drawImage(img, 0, 0, getWidth(),getHeight(),null);
			break;
		case -9 :
			img = (new ImageIcon("./button/mine1.jpg")).getImage();
			g.drawImage(img, 0, 0, getWidth(),getHeight(),null);
			break;
		case -10 :
			img = (new ImageIcon("./button/mine2.jpg")).getImage();
			g.drawImage(img, 0, 0, getWidth(),getHeight(),null);
			break;
		case -11 :
			img = (new ImageIcon("./button/mineflag.jpg")).getImage();
			g.drawImage(img, 0, 0, getWidth(),getHeight(),null);
			break;
		}
	}
	
	public int getType(){
		return type;
	}
	
	public void setType(int x){
		type = x;
		repaint();
	}

}
